package com.rabbitmq.delayplugin.receiver;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

import static com.rabbitmq.delayplugin.config.RabbitMQConfig.DELAY_QUEUE_NAME;

@Component
@Slf4j
public class RabbitMQDelayPluginReceiver {

    @RabbitListener(queues = {DELAY_QUEUE_NAME})
    public void receive(Message message){
        String s = new String(message.getBody());
        log.info("当前时间:【{}】,延迟队列接收到得消息:【{}】", LocalDateTime.now(),s);
    }
}
